#include "Thread.h"

Thread::Thread(){
	this->boolStop = false;
}

Thread::Thread(size_t stacksize){
	this->boolStop = false;
	pthread_attr_setstacksize(&attr, stacksize);
}

Thread::~Thread(){
}

int Thread::start(){
	this->boolStop = false;
	int aux = pthread_create((&thread), NULL, start_routine,(void*)this);
	return aux;
}

void* Thread::start_routine(void* arg){
	Thread *p = (Thread*) arg;
	p->run();
	return 0;
}

void* Thread::join(){
	void* r;
	pthread_join(thread,&r);
	return r;
}

void Thread::stop(){
	this->boolStop = true;
}

bool Thread::getStop(){
	return this->boolStop;
}
